<template>
  <div>
    <el-form ref="form" v-loading="loading" :model="entity" :rules="rules" label-width="80px">

      <el-form-item label="标题" prop="title">
        <el-input v-model="entity.title"></el-input>
      </el-form-item>
      <el-form-item label="缩略图" prop="image">
        <uploader :value.sync="entity.image"></uploader>
      </el-form-item>
      <el-form-item label="内容" prop="content">
        <rich-edit :value.sync = "entity.content"></rich-edit>
      </el-form-item>
      <el-form-item>
        <el-button @click="handleSave()">草稿</el-button>
        <el-button type="primary" @click="handleRelease()">发布</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { mapGetters } from 'vuex';
import ArticleAPI from '@/api/homepage/article';
import { EditMethods } from '@/utils/crud';
import Uploader from '../../components/Uploader';
import RichEdit from '../../components/RichEditor';

export default {
    components: {
        Uploader,
        RichEdit
    },
    props: {
        id: {
            type: String,
            default: ''
        }
    },
    data: function() {
        return {
            loading: 0,
            entity: {
                image: null,
                title: null,
                status: 0
            },
            rules: {
                title: {
                    required: true, trigger: 'blur'
                }
            }
        };
    },
    computed: {
        ...mapGetters([
            'dictionary'
        ])
    },
    created: function() {
        this.init();
    },
    methods: Object.assign(EditMethods(ArticleAPI), {
    })
};
</script>

<style lang="scss">

</style>
